package co.fitstart.admin.entity.report;

import java.util.Date;

import com.demo2do.core.utils.DateFormatUtils;
import com.demo2do.core.utils.DateUtils;
import com.demo2do.core.utils.StringUtils;

import co.fitstart.entity.coach.CoachRestType;
import co.fitstart.entity.course.CourseType;

/**
 * 
 * @author YSY
 *
 */
public class HourlySchedule {

    private String day;
    
    private String coach;
    
    private String hour;
    
    private String scheduleType;
    
    /**
     * 
     * the default constructor
     */
    public HourlySchedule(){
        
    }

    
    /**
     * 
     * @param day
     * @param coach
     * @param hour
     * @param scheduleType
     */
    public HourlySchedule(String day, String coach, String hour, String scheduleType) {
        this.day = day;
        this.coach = coach;
        this.hour = hour;
        this.scheduleType = scheduleType;
    }

    /**
     * 
     * @param day
     * @param coach
     * @param hour
     * @param scheduleType
     */
    public HourlySchedule(Date day, String coach, String hour, CourseType scheduleType) {
        this.day = DateFormatUtils.format(day, "yyyy-MM-dd");
        this.coach = coach;
        this.hour = hour;
        this.scheduleType = scheduleType.getOther();
    }
    
    /**
     * 
     * @param day
     * @param coach
     * @param hour
     * @param scheduleType
     * @param experience
     */
    public HourlySchedule(Date day, String coach, String hour, CourseType scheduleType, boolean experience, boolean give) {
        this.day = DateFormatUtils.format(day, "yyyy-MM-dd");
        this.coach = coach;
        this.hour = hour;
        this.scheduleType = (scheduleType.isIndividual() || scheduleType.isSpecial() || scheduleType.isPosture()) && experience ? "体验课" : ((scheduleType.isIndividual() || scheduleType.isSpecial() || scheduleType.isPosture()) && give ? "赠课" : scheduleType.getOther());
    }
    
    /**
     * 
     * @param day
     * @param coach
     * @param hour
     * @param scheduleType
     */
    public HourlySchedule(Date day, String coach, String hour,  CoachRestType scheduleType) {
        this.day = DateFormatUtils.format(day, "yyyy-MM-dd");
        this.coach = coach;
        this.hour = hour;
        this.scheduleType = scheduleType.getDescription();
    }

    /**
     * 
     * @return
     */
    public HourlySchedule addHalfHour(){
        String dayHour = StringUtils.connect(this.day, " ", this.hour);
        Date dayHourTime = DateUtils.parseDate(dayHour, "yyyy-MM-dd HH:mm");
        Date result = org.apache.commons.lang3.time.DateUtils.addMinutes(dayHourTime, 30);
        String hour = DateFormatUtils.format(result, "HH:mm");
        
        return new HourlySchedule(this.day, this.coach, hour, this.scheduleType);
    }
    
    /**
     * 
     * @return
     */
    public boolean isDuty(){
        return this.scheduleType.equals("值班");
    }
    
    /**
     * 
     * @return
     */
    public String getDhc(){
        return StringUtils.connect(this.day + "|" + this.hour +"|" + this.coach);
    }
    
    /**
     * 
     * @return
     */
    public String getDh(){
        return StringUtils.connect(this.day + "|" + this.hour);
    }
    
    /**
     * @return the day
     */
    public String getDay() {
        return day;
    }

    /**
     * @return the coach
     */
    public String getCoach() {
        return coach;
    }

    /**
     * @return the hour
     */
    public String getHour() {
        return hour;
    }

    /**
     * @return the scheduleType
     */
    public String getScheduleType() {
        return scheduleType;
    }

    /**
     * @param day the day to set
     */
    public void setDay(String day) {
        this.day = day;
    }

    /**
     * @param coach the coach to set
     */
    public void setCoach(String coach) {
        this.coach = coach;
    }

    /**
     * @param hour the hour to set
     */
    public void setHour(String hour) {
        this.hour = hour;
    }

    /**
     * @param scheduleType the scheduleType to set
     */
    public void setScheduleType(String scheduleType) {
        this.scheduleType = scheduleType;
    }
}
